﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MLBService.Resources;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Web;
using System.ComponentModel;

namespace MLBService.Interfaces
{
    [ServiceKnownType(typeof(System.ServiceModel.Syndication.Atom10FeedFormatter))]
    [ServiceKnownType(typeof(System.ServiceModel.Syndication.Rss20FeedFormatter))]
    [ServiceContract]
    public interface IMlb
    {
        [WebGet(UriTemplate = "franchisefeed")]
        [OperationContract]
        System.ServiceModel.Syndication.SyndicationFeedFormatter GetFranchiseFeed();

        [OperationContract]
        [WebGet(UriTemplate = "franchises/all", ResponseFormat = WebMessageFormat.Json)]
        [Description("List of all franchises, active or defunct")]
        FranchiseList GetAllFranchises();
        
        [OperationContract]
        [WebGet(UriTemplate = "franchises/current", ResponseFormat = WebMessageFormat.Json)]
        [Description("List of current franchises")]
        FranchiseList GetCurrentFranchises();

        [OperationContract]
        [WebInvoke(UriTemplate="franchise", Method="PUT")]
        [Description("Adds franchise")]
        void AddFranchise(FranchiseItem franchise);

        [OperationContract]
        [WebInvoke(UriTemplate = "franchise/{franchiseId}", Method = "DELETE")]
        void DeleteFranchise(string franchiseId);

        [OperationContract]
        [WebInvoke(UriTemplate = "team/{franchiseId}", Method = "POST")]
        void AddTeam(string franchiseId);

        [OperationContract]
        [WebGet(UriTemplate = "franchises/{year}", ResponseFormat = WebMessageFormat.Json)]
        [Description("List of all teams who played in given year")]
        TeamList GetTeamsByYear(string year);
        
        [OperationContract]
        [WebGet(UriTemplate = "franchise/{franchiseid}", ResponseFormat = WebMessageFormat.Json)]
        [Description("Franchise object with list of teams for the given franchise")]
        FranchiseItem GetFranchiseById(string franchiseid);
        
        [OperationContract]
        [WebGet(UriTemplate = "teams/{franchiseid}", ResponseFormat = WebMessageFormat.Json)]
        [Description("List of teams for the given franchise")]
        FranchiseItem GetTeamsByFranchiseId(string franchiseid);
        
        [OperationContract]
        [WebGet(UriTemplate = "team/{teamid}", ResponseFormat = WebMessageFormat.Json)]
        [Description("Team object with list of players for the given team")]
        TeamItem GetTeamByTeamId(string teamid);
        
        [OperationContract]
        [WebGet(UriTemplate = "players/{teamid}", ResponseFormat = WebMessageFormat.Json)]
        [Description("List of players for the given team")]
        PlayerList GetPlayersByTeamId(string teamid);
        
        [OperationContract]
        [WebGet(UriTemplate = "player/{playerid}", ResponseFormat = WebMessageFormat.Json)]
        [Description("Player object with career stats")]
        PlayerItem GetPlayerByPlayerId(string playerid);
        
        [OperationContract]
        [WebGet(UriTemplate = "stats/batting/{playerid}/{year}", ResponseFormat = WebMessageFormat.Json)]
        [Description("Yearly batting stats for given player in given year")]
        BattingStatsItem GetYearlyBattingStatsForPlayer(string playerid, string year);
        
        [OperationContract]
        [WebGet(UriTemplate = "stats/fielding/{playerid}/{year}", ResponseFormat = WebMessageFormat.Json)]
        [Description("Yearly fielding stats for given player in given year")]
        FieldingStatsItem GetYearlyFieldingStatsForPlayer(string playerid, string year);
        
        [OperationContract]
        [WebGet(UriTemplate = "stats/pitching/{playerid}/{year}", ResponseFormat = WebMessageFormat.Json)]
        [Description("Yearly pitching stats for given player in given year")]
        PitchingStatsItem GetYearlyPitchingStatsForPlayer(string playerid, string year);
        
        [OperationContract]
        [WebGet(UriTemplate = "stats/batting/{playerid}", ResponseFormat = WebMessageFormat.Json)]
        [Description("Career batting stats for given player")]
        CareerBattingStatsList GetCareerBattingStatsForPlayer(string playerid);
        
        [OperationContract]
        [WebGet(UriTemplate = "stats/fielding/{playerid}", ResponseFormat = WebMessageFormat.Json)]
        [Description("Career fielding stats for given player")]
        CareerFieldingStatsList GetCareerFieldingStatsForPlayer(string playerid);
        
        [OperationContract]
        [WebGet(UriTemplate = "stats/pitching/{playerid}", ResponseFormat = WebMessageFormat.Json)]
        [Description("Career pitching stats for given player")]
        CareerPitchingStatsList GetCareerPitchingStatsForPlayer(string playerid);
    }
}
